package com.dong.selector;

import com.dong.config.T023ImportConfig;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

import java.util.Set;

/**
 * 用于测试 import方式向容器注册组件
 * @see T023ImportConfig
 *
 * 可以拿到类的全部注解
 *
 *   返回需要导入类的全类名的字符串数组.
 */
public class MyImportSelector implements ImportSelector {
    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        Set<String> annotationTypes = importingClassMetadata.getAnnotationTypes();
        System.out.println("获取注解类型 ---> 开始");
        annotationTypes.stream().forEach(System.out::println);
        System.out.println("获取注解类型 ---> 结束");
        return new String[]{"com.com.dong.bean.Blue"};
    }
}
